package com.huatai.paas.service.impl;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.huatai.bi.dto.BigScreenPageDTO;
import com.huatai.bi.feign.BiClient;
import com.huatai.common.api.R;
import com.huatai.common.config.MinioAPI;
import com.huatai.common.constant.MinioCommonBucket;
import com.huatai.common.entity.UserInfo;
import com.huatai.common.error.exception.ServiceException;
import com.huatai.common.util.*;
import com.huatai.paas.dto.*;
import com.huatai.paas.dto.info.QueryFileMessageInfo;
import com.huatai.paas.dto.info.QueryProjectManagementInfo;
import com.huatai.paas.entity.FileListEntity;
import com.huatai.paas.entity.InputData;
import com.huatai.paas.entity.ServerInfo;
import com.huatai.paas.mapper.ProjectManagementMapper;
import com.huatai.paas.service.*;
import com.huatai.paas.utils.HttpsUtil;
import com.huatai.paas.websocket.StatusChangeWebsocketHandler;
import okhttp3.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

/**
 * <b>ProjectManagementServiceImpl</b>
 *
 * @description: ProjectManagementServiceImpl <br>
 * @date: 2024/7/22 09:21 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Service
public class ProjectManagementServiceImpl extends ServiceImpl<ProjectManagementMapper, ProjectManagement> implements ProjectManagementService {
	private static final Logger logger = LoggerFactory.getLogger(ProjectManagementServiceImpl.class);

	@Autowired
	private MinioAPI minioAPI;

	@Autowired
	private ItemModelMessageService itemModelMessageService;

	@Autowired
	private StatusChangeWebsocketHandler statusChangeWebsocketHandler;

	@Autowired
	@Lazy
	private ModelManagementService modelManagementService;

	@Autowired
	private FileListService fileListService;

	@Autowired
	private BiClient biClient;

	@Value("${minio.PREURL}")
	private String minioApi;

	@Value("${minio.PREURL}")
	private String minioUrl;

	@Value("${main.toolPort}")
	private String toolPort;

	@Value("${main.masterIp}")
	private String masterIp;

	@Value("${main.path}")
	private String path;

//	@Value("${main.ip}")
	private String ip = System.getenv("HOST_IP");

	@Value("${main.port}")
	private String port;

	private final static String SLASH = "/";

	private final static String FILE_NAME_PREFIX_SEPARATOR = "-";

	@Override
	public IPage<QueryProjectManagementInfo> queryProjectManageList(QueryProjectManagementDto dto) {
		UserInfo userInfo = AuthUtil.getUser();
		if (0 == dto.getPageNum()){
			dto.setPageNum(1);
		}
		if (0 == dto.getPageSize()){
			dto.setPageSize(10);
		}
		Page<QueryProjectManagementInfo> page = new Page<>(dto.getPageNum(), dto.getPageSize());
//		List<Long> departmentList = new ArrayList<>();
//		List<Long> departmentIds = new ArrayList<>();
//		departmentList.add(userInfo.getDeptId());
//		departmentIds.add(userInfo.getDeptId());
//		getDepartmentIdList(departmentIds,departmentList);
		IPage<QueryProjectManagementInfo> pageInfo = baseMapper.queryProjectManageList(page,dto.getStatus(),dto.getItemName(),null,userInfo.getUserId());
		return pageInfo;
	}

	public void getDepartmentIdList(List<Long> departmentIds,List<Long> departmentList){
		List<Long> idList = baseMapper.queryDepartmentList(departmentIds);
		if (CollectionUtil.isNotEmpty(idList)){
			return;
		}else {
			departmentList.addAll(idList);
		}
		getDepartmentIdList(idList,departmentList);
	}

	@Override
	public R addProjectManagement(CreateProjectManagementDto dto) {
		FileListEntity fileListEntity = null;
		if(StringUtil.isNotBlank(dto.getSenceFileMd5())){
			fileListEntity = fileListService.queryFileByMd5(dto.getSenceFileMd5());
			if(fileListEntity == null){
				return R.fail("场景文件信息异常");
			}
		}
		UserInfo userInfo = AuthUtil.getUser();
		ProjectManagement projectManagement = new ProjectManagement();
		projectManagement.setId(IdWorker.getId());
		projectManagement.setItemName(dto.getItemName());
		projectManagement.setFileId(dto.getFileId());
		projectManagement.setItemDescribe(dto.getItemDescribe());
		projectManagement.setCoverUrl(dto.getCoverUrl());
		projectManagement.setStatus("0");
		projectManagement.setEnable("1");
		projectManagement.setCreateUser(userInfo.getUserId());
		projectManagement.setUpdateUser(userInfo.getUserId());
		projectManagement.setCreateTime(new Date());
		projectManagement.setUpdateTime(new Date());
		projectManagement.setServerId(dto.getServerId());
		projectManagement.setServerName(dto.getServerName());
		projectManagement.setLat(dto.getLat());
		projectManagement.setLng(dto.getLng());
		projectManagement.setServerName(dto.getServerName());
		if(fileListEntity != null){
			projectManagement.setSenceFileId(fileListEntity.getId());
			projectManagement.setEnable("2");
		}
		baseMapper.insert(projectManagement);

		if(fileListEntity != null){
			OkHttpClient client = new OkHttpClient();
			JSONObject paramData = new JSONObject();
			List<String> dataList = new LinkedList<>();
			dataList.add(minioAPI.getENDPOINT()+fileListEntity.getPath());
			paramData.put("list",dataList);
			paramData.put("callUrl","http://" + ip + ":" + port +"/ht-paas/transform/modelManagement?type=1&itemId="+projectManagement.getId()+"&status=");

			RequestBody body = RequestBody.create(MediaType.parse("application/json"), paramData.toJSONString());
			String requestUrl = masterIp + ":" + toolPort + path;
			// 创建 HTTP 请求
			Request request = new Request.Builder()
				.url(requestUrl)
				.post(body)
				.build();
			// 发送异步请求
			client.newCall(request).enqueue(new Callback() {
				@Override
				public void onFailure(Call call, IOException e) {
					log.error("地形转换服务器异常："+e.getMessage());
					projectManagement.setEnable("3");
					baseMapper.updateById(projectManagement);
				}
				@Override
				public void onResponse(Call call, Response response) throws IOException {
				}
			});
		}
		statusChangeWebsocketHandler.sendMessageToAllUser("新增项目信息", projectManagement);

		if(dto.getScreenData() == null){
			String s = "{\"name\": \"首页\", \"orderNum\": 0, \"type\": \"bigScreenCatalog\", \"chartList\": [], \"coverPicture\": \"\", \"id\": \"\", \"code\": \"\", \"config\": {\"w\": 1920, \"h\": 1080, \"bgColor\": \"transparent\"}}";
			dto.setScreenData(JSONObject.parseObject(s, BigScreenPageDTO.class));
		}
		R<String> r = biClient.addScreen(dto.getScreenData());
		System.out.println("态势创建结果："+r);
		if(r.isSuccess()){
			JSONObject sceenJson = new JSONObject();
			sceenJson.put(r.getData(),"首页");
			projectManagement.setFileId(sceenJson.toJSONString());
			baseMapper.updateById(projectManagement);
		}
		return R.data(projectManagement.getId());
	}

	@Override
	public R updateProjectManagement(UpdateProjectManagementDto dto) {
		if(dto.getId() == null){
			return R.fail("数据ID不能为空");
		}
		ProjectManagement projectManagement = this.baseMapper.selectById(dto.getId());
		if(projectManagement == null){
			return R.fail("项目信息异常");
		}

		if(dto.getType() != null &&  dto.getType().intValue() == 1){
			//只更新封面图片
			if(StringUtil.isBlank(dto.getCoverUrl())){
				return R.data(projectManagement);
			}
			try {
				String baseStr = dto.getCoverUrl().split(",")[1];
				byte[] decodedBytes = Base64.getDecoder().decode(baseStr);
				String pdfFilePath = System.currentTimeMillis()+".png";
				InputStream is = new ByteArrayInputStream(decodedBytes);
				String bucketName = MinioCommonBucket.GANGHUA_PUB_BUCKET_URL;
				String objectKey = getObjectKey((long) decodedBytes.length, pdfFilePath);
				minioAPI.uploadInputStream(bucketName, objectKey, is, "application/png");
				logger.info("上传地址为:{}"+objectKey);
				String cover = minioUrl+"/"+MinioCommonBucket.GANGHUA_PUB_BUCKET_URL+"/"+objectKey;
				projectManagement.setCoverUrl(cover);
				baseMapper.updateById(projectManagement);
			} catch (Exception e) {
				logger.error("项目封面图片上传失败，", e);
				throw new ServiceException("项目封面图片上传失败，请重新上传");
			}
			return R.data(projectManagement);
		}

		if(StringUtil.isNotBlank(dto.getItemName())){
			projectManagement.setItemName(dto.getItemName());
		}
		if(StringUtil.isNotBlank(dto.getFileId())){
			projectManagement.setFileId(dto.getFileId());
		}
		if(StringUtil.isNotBlank(dto.getItemDescribe())){
			projectManagement.setItemDescribe(dto.getItemDescribe());
		}
		if(StringUtil.isNotBlank(dto.getCoverUrl())){
			projectManagement.setCoverUrl(dto.getCoverUrl());
		}
		projectManagement.setUpdateTime(new Date());
		if(dto.getServerId() != null){
			projectManagement.setServerId(dto.getServerId());
		}
		if(StringUtil.isNotBlank(dto.getServerName())){
			projectManagement.setServerName(dto.getServerName());
		}
		if(StringUtil.isNotBlank(dto.getLat())){
			projectManagement.setLat(dto.getLat());
		}
		if(StringUtil.isNotBlank(dto.getLng())){
			projectManagement.setLng(dto.getLng());
		}
		if(StringUtil.isNotBlank(dto.getSenceFileMd5())){
			FileListEntity fileListEntity = fileListService.queryFileByMd5(dto.getSenceFileMd5());
			if(fileListEntity != null){
				projectManagement.setSenceFileId(fileListEntity.getId());
				projectManagement.setEnable("2");
				baseMapper.updateById(projectManagement);

				OkHttpClient client = new OkHttpClient();
				JSONObject paramData = new JSONObject();
				List<String> dataList = new LinkedList<>();
				dataList.add(minioAPI.getENDPOINT()+fileListEntity.getPath());
				paramData.put("list",dataList);
				paramData.put("callUrl","http://" + ip + ":" + port +"/ht-paas/transform/modelManagement?type=1&itemId="+projectManagement.getId()+"&status=");

				RequestBody body = RequestBody.create(MediaType.parse("application/json"), paramData.toJSONString());
				String requestUrl = masterIp + ":" + toolPort + path;
				// 创建 HTTP 请求
				Request request = new Request.Builder()
					.url(requestUrl)
					.post(body)
					.build();
				// 发送异步请求
				client.newCall(request).enqueue(new Callback() {
					@Override
					public void onFailure(Call call, IOException e) {
						log.error("地形转换服务器异常："+e.getMessage());
						projectManagement.setEnable("3");
						baseMapper.updateById(projectManagement);
					}
					@Override
					public void onResponse(Call call, Response response) throws IOException {
					}
				});
			}
		}

		baseMapper.updateById(projectManagement);
		return R.data(projectManagement);
	}

	@Override
	public boolean deleteProjectManagement(long id) {
		UpdateWrapper updateWrapper = new UpdateWrapper();
		updateWrapper.eq("id",id);
		updateWrapper.set("enable","0");
		int update = baseMapper.update(null, updateWrapper);
		if (1 == update){
			return true;
		}
		return false;
	}

	public Boolean getServerStatus(String serverIp) {
		String url = "http://" + serverIp + ":" + toolPort + "/serverStatus";
		try {
			Response response = OkHttpUtil.sendOkHttpClientWithResponse(url, "GET", null, null);
			if (response != null && response.isSuccessful()) {
				return true;
			} else {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
	}

	@Override
	public R publishProjectManagement(PublishProjectManagementDto dto) {
		if(dto.getId() == null){
			return R.fail("数据ID不能为空");
		}
		ProjectManagement management = this.baseMapper.selectById(dto.getId());
		if(management == null){
			return R.fail("项目信息异常");
		}
		if(management.getServerId() == null){
			return R.fail("请先给项目绑定服务器信息");
		}
		ServerInfo serverInfo = this.baseMapper.getServerInfoById(management.getServerId());
		if(serverInfo == null){
			return R.fail("服务器信息异常，请核查");
		}
		if(StringUtil.isBlank(serverInfo.getServerIp())){
			return R.fail("服务器连接信息异常");
		}

		if(!getServerStatus(serverInfo.getServerIp())){
			return R.fail("服务器连接状态异常");
		}

		management.setStatus("2");
		management.setTissueId(dto.getTissueId());
		management.setUpdateTime(new Date());
		management.setPublishTime(new Date());
		this.baseMapper.updateById(management);

		List<String> dataList = new LinkedList<>();
		List<ItemModelMessage> itemModelMessageList = itemModelMessageService.queryItemModelListByItemId(management.getId());
		for (ItemModelMessage itemModelMessage : itemModelMessageList) {
			dataList.add(minioAPI.getENDPOINT()+itemModelMessage.getPath());
		}
		if(management.getSenceFileId() != null){
			//查询项目的场景文件
			FileListEntity fileListEntity = fileListService.getById(management.getSenceFileId());
			dataList.add(minioAPI.getENDPOINT()+fileListEntity.getPath());
		}

		if(dataList.size() == 0){
			//无下载资源清单则直接发布完成
			management.setStatus("1");
			this.baseMapper.updateById(management);
			return R.success("发布成功");
		}

		OkHttpClient client = new OkHttpClient();
		JSONObject paramData = new JSONObject();
		paramData.put("list",dataList);
		paramData.put("callUrl","http://" + ip + ":" + port +"/ht-paas/project/publish/status?itemId="+management.getId()+"&status=");

		RequestBody body = RequestBody.create(MediaType.parse("application/json"), paramData.toJSONString());
		String requestUrl = "http://" + serverInfo.getServerIp() + ":" + toolPort + path;
		// 创建 HTTP 请求
		Request request = new Request.Builder()
			.url(requestUrl)
			.post(body)
			.build();
		// 发送异步请求
		client.newCall(request).enqueue(new Callback() {
			@Override
			public void onFailure(Call call, IOException e) {
				log.error("地形转换服务器异常："+e.getMessage());
				management.setStatus("3");
				baseMapper.updateById(management);
			}
			@Override
			public void onResponse(Call call, Response response) throws IOException {
			}
		});
		return R.success("发布申请已提交");
	}

	@Override
	public String uploadCoverUrl(MultipartFile file) {
		try (InputStream is = file.getInputStream()) {
			String bucketName = MinioCommonBucket.HUATAI_PUB_BUCKET;
			String objectKey = getObjectKey(file.getSize(), file.getOriginalFilename());
			minioAPI.uploadInputStream(bucketName, objectKey, is, file.getContentType());
			logger.info("上传地址为:{}"+objectKey);
			return minioUrl+"/"+MinioCommonBucket.HUATAI_PUB_BUCKET+"/"+objectKey;
		} catch (Exception e) {
			log.error("上传失败，", e);
			throw new ServiceException("上传失败，请重新上传");
		}
	}

//	@Override
//	public boolean saveItemDisposition(CreateItemDispositionDto dto) {
//		UpdateWrapper updateWrapper = new UpdateWrapper();
//		updateWrapper.eq("id",dto.getId());
//		updateWrapper.set("data",dto.getData());
//		int update = baseMapper.update(null, updateWrapper);
//		//根据所有模型ID查询模型列表
//		List<ModelManagement> modelList = modelManagementService.queryModelListById(dto.getModelIdList());
//		if (modelList.size() > 0){
//			List<ItemModelMessage> itemModelMessageList = new ArrayList<>();
//			modelList.forEach(item -> {
//				ItemModelMessage itemModelMessage = new ItemModelMessage();
//				itemModelMessage.setItemId(dto.getId());
//				itemModelMessage.setModelId(item.getId());
//				itemModelMessage.setFileId(item.getFileId());
//				itemModelMessageList.add(itemModelMessage);
//			});
//			itemModelMessageService.saveBatch(itemModelMessageList);
//		}
//		if (1 == update){
//			return true;
//		}
//		return false;
//	}
	@Override
	public boolean saveItemDisposition(CreateItemDispositionDto dto) {
		UpdateWrapper updateWrapper = new UpdateWrapper();
		updateWrapper.eq("id",dto.getId());
		updateWrapper.set(StringUtil.isNotBlank(dto.getData()),"data",dto.getData());
		updateWrapper.set(StringUtil.isNotBlank(dto.getDataGlobal()),"data_global",dto.getDataGlobal());
		updateWrapper.set(StringUtil.isNotBlank(dto.getBuildingModeConfig()),"building_mode_config",dto.getBuildingModeConfig());
		updateWrapper.set(StringUtil.isNotBlank(dto.getCameraConfig()),"camera_config",dto.getCameraConfig());
		updateWrapper.set(StringUtil.isNotBlank(dto.getKeybordEvent()),"keybord_event",dto.getKeybordEvent());
		int update = baseMapper.update(null, updateWrapper);

		if(dto.getModels().size() > 0){
			//查询项目已绑定id
			List<Long> OlderIdList = itemModelMessageService.getModelIdById(dto.getId());
			List<Long> models = dto.getModels();
			//删除已有id
			models.removeAll(OlderIdList);
			List<ModelManagement> modelList = new ArrayList<>();
			if (models.size() > 0 ){
				modelList = modelManagementService.queryModelListById(models);
			}
			//根据所有模型ID查询模型列表
			if (modelList.size() > 0){
				List<ItemModelMessage> itemModelMessageList = new ArrayList<>();
				modelList.forEach(item -> {
					ItemModelMessage itemModelMessage = new ItemModelMessage();
					itemModelMessage.setItemId(dto.getId());
					itemModelMessage.setModelId(item.getId());
					itemModelMessage.setFileId(item.getFileId());
					itemModelMessageList.add(itemModelMessage);
				});
				itemModelMessageService.saveOrUpdateBatch(itemModelMessageList);
			}
		}
		if (1 == update){
			return true;
		}
		return false;
	}

	@Override
	public boolean unPublishItemDisposition(PublishProjectManagementDto dto) {
		UpdateWrapper updateWrapper = new UpdateWrapper();
		updateWrapper.eq("id",dto.getId());
		updateWrapper.set("status","0");
		updateWrapper.set("tissue_id",null);
		int update = baseMapper.update(null, updateWrapper);
		if (1 == update){
			return true;
		}
		return false;
	}

	@Override
	public QueryProjectManagementInfo queryItemDispositionInfo(Long id) {
		QueryProjectManagementInfo info = baseMapper.queryItemDispositionInfo(id);
		if(info != null){
			if(info.getSenceFileId() != null){
				FileListEntity entity = fileListService.getById(info.getSenceFileId());
				if(entity != null){
					info.setSenceFileInfo(entity);
				}
			}
			if(info.getServerId() != null){
				ServerInfo serverInfo = this.baseMapper.getServerInfoById(info.getServerId());
				info.setServerInfo(serverInfo);
			}
		}
		return info;
	}

	@Override
	public Map<String, Object> queryFileList(Long itemId) {
		ProjectManagement projectManagement = this.baseMapper.selectById(itemId);
		if(projectManagement == null){
			return null;
		}
		Map<String,Object> resultMap = new HashMap<>();
		resultMap.put("Version","0.2");
		resultMap.put("FileServerAddressRoot",minioApi);
		Map<String,Map<String,String>> mapResult = new LinkedHashMap<>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		//根据项目ID查询项目关联模型列表
		List<ItemModelMessage> itemModelMessageList = itemModelMessageService.queryItemModelListByItemId(itemId);
		for (ItemModelMessage itemModelMessage : itemModelMessageList) {
			Map<String,String> map = new LinkedHashMap<>();
			Date uploadTime = itemModelMessage.getUploadTime();
			map.put("ResourceUpdateTime",sdf.format(uploadTime));
			map.put("MD5",itemModelMessage.getIdentifier());
			map.put("RelativePath",itemModelMessage.getUePath());
			mapResult.put(itemModelMessage.getIdentifier(),map);
		}

		if(projectManagement.getSenceFileId() != null){
			//查询项目的场景文件
			FileListEntity fileListEntity = fileListService.getById(projectManagement.getSenceFileId());
			if(fileListEntity != null && StringUtil.isNotBlank(fileListEntity.getUePath())){
				Map<String,String> map = new LinkedHashMap<>();
				map.put("ResourceUpdateTime",sdf.format(fileListEntity.getUploadTime()));
				map.put("MD5",fileListEntity.getIdentifier());
				map.put("RelativePath",fileListEntity.getUePath());
				mapResult.put(fileListEntity.getIdentifier(),map);
			}
		}

		resultMap.put("EnvironmentResourceList",mapResult);
		return resultMap;
	}

	@Override
	public R projectPublishStatus(Long itemId,String status) {
		if(StringUtil.equals("0",status)){
			status = "3";
		}
		ProjectManagement management = this.baseMapper.selectById(itemId);
		if(management == null){
			return R.fail("项目信息异常");
		}
		management.setStatus(status);
		management.setUpdateTime(new Date());
		this.baseMapper.updateById(management);
		statusChangeWebsocketHandler.sendMessageToAllUser("目标服务器命令执行回执", this.baseMapper.selectById(itemId));
		return R.success("发布成功");
	}

	@Override
	public ProjectManagement getProjectById(Long projectId) {
		return this.baseMapper.selectById(projectId);
	}

	@Override
	public void updateProject(ProjectManagement projectManagement) {
		this.baseMapper.updateById(projectManagement);
	}

	@Override
	public R projectWeather(String lat, String lng) {
		String url = "http://gfapi.mlogcn.com/high_res/v001/gridnow?key=IgDdtTVnz51nJBSHcXPoF6d5HOpy8mOn&lonlat="+lng+","+lat;
		Object resultObj = OkHttpUtil.sendOkHttpClient(url, "GET", null, null);
		JSONObject dataJson = JSONObject.parseObject(resultObj.toString());
		return R.data(dataJson);
	}

	@Override
	public R ueRequestBack(UeRequestBackDto dto) {
		if(dto.getRequestUrl().indexOf("https") > -1){
			RequestBody body = RequestBody.create(MediaType.get("application/json"), JSON.toJSONString(dto.getParams()));

			// 使用忽略证书的OkHttpClient
			OkHttpClient client = HttpsUtil.getUnsafeOkHttpClient();

			Request request = new Request.Builder()
				.url(dto.getRequestUrl())
				.post(body)
				.build();

			Object resultData = null;
			try (Response response = client.newCall(request).execute()) {
				if (response.isSuccessful() && response.body() != null) {
					resultData = response.body().string();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}

			return R.data(resultData);
		}else{
			RequestBody body = RequestBody.create(MediaType.get("application/json"), JSON.toJSONString(dto.getParams()));
			Object resultData = OkHttpUtil.sendOkHttpClient(dto.getRequestUrl(), "POST", body, null);
			return R.data(resultData);
		}
	}

	/**
	 * 获取存储路径
	 * @param fileSize
	 * @param fileName
	 * @return
	 */
	private String getObjectKey(Long fileSize,String fileName) {
		String date = DateTimeUtil.format(LocalDate.now(),"yyyyMMdd");

		StringBuilder objectKey = new StringBuilder(date);
		objectKey.append(SLASH).append(fileSize).append(FILE_NAME_PREFIX_SEPARATOR).append(fileName);
		return objectKey.toString();
	}
}
